@extends('admin.layout.main')

@section('content')
<div class="breadcrumbs ace-save-state" id="breadcrumbs">
<ul class="breadcrumb">
	<li>
		<i class="ace-icon fa fa-home home-icon"></i>
		<a href="/admin/index">首页</a>
	</li>
	<li>
		<a href="#">管理员管理</a>
	</li>
	<li class="active"><a href="{{ url('admin/admin') }}">管理员列表</a></li>
</ul><!-- /.breadcrumb -->

</div>
<div class="page-content">
	<div class="row">
		<div class="col-xs-12">
			<!-- PAGE CONTENT BEGINS -->
			<div class="row">
				<div class="col-xs-12">
					<div class="clearfix">
						<div class="pull-right tableTools-container"></div>
					</div>
					<div class="table-header">
						<a href="{{ url('admin/admin/create') }}">
						<i class="menu-icon fa fa-plus orange"></i>
						<span class="menu-text orange"> 添加管理员 </span>
						</a>
					</div>

					<!-- div.table-responsive -->

					<!-- div.dataTables_borderWrap -->
					<div>
						<table id="dynamic-table" class="table table-striped table-bordered table-hover">
							<thead>
								<tr>
									<th>序号</th>
									<th>管理员名</th>
									<th>所属角色</th>
									<th class="hidden-480">创建时间</th>

									<th>
										<i class="ace-icon fa fa-clock-o bigger-110 hidden-480"></i>
										更新时间
									</th>
									<th class="hidden-480">Status</th>

									{{--<th></th>--}}
								</tr>
							</thead>

							<tbody>
							@foreach($list as $key=>$data)
								<tr>
									<td>{{$page_num++}}</td>
									<td>{{$data->username}}</td>
									<td>
										@foreach($data['roles'] as $item)
											<span class="label label-sm label-info">{{$item['name']}}</span>
										@endforeach
									</td>
									<td>{{$data->created_at}}</td>
									<td>{{$data->updated_at}}</td>
									<td><div class="hidden-sm hidden-xs action-buttons">

											<a class="green" href="/admin/admin/{{$data->id}}/edit">
												<i class="ace-icon fa fa-pencil bigger-130"></i>
											</a>

											<a class="red"
											   @if($data->id == 1)
											   href="#"
											   @else
											   href="javascript:void(0)" onclick="delData('{{$data->id}}')"

												@endif
											>
												<i class="ace-icon fa fa-trash-o bigger-130"></i>
											</a>
										</div>

										<div class="hidden-md hidden-lg">
											<div class="inline pos-rel">
												<button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown" data-position="auto">
													<i class="ace-icon fa fa-caret-down icon-only bigger-120"></i>
												</button>

												<ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">


													<li>
														<a href="/admin/admin/{{$data->id}}/edit" class="tooltip-success" data-rel="tooltip" title="Edit">
															<span class="green">
																<i class="ace-icon fa fa-pencil-square-o bigger-120"></i>
															</span>
														</a>
													</li>

													<li>
														<a
																@if($data->id == 1)
																href="#"
																		@else
																href="javascript:void(0)" onclick="delData('{{$data->id}}')"
														   @endif
														    class="tooltip-error" data-rel="tooltip" title="Delete">
															<span class="red">
																<i class="ace-icon fa fa-trash-o bigger-120"></i>
															</span>
														</a>
													</li>
												</ul>
											</div>
										</div>
									</td>
								</tr>
							@endforeach
								{{--<tr>--}}
									{{--<td>--}}
										{{--<a href="#">app.com</a>--}}
									{{--</td>--}}
									{{--<td>$45</td>--}}
									{{--<td class="hidden-480">3,330</td>--}}
									{{--<td>Feb 12</td>--}}

									{{--<td class="hidden-480">--}}
										{{--<span class="label label-sm label-warning">Expiring</span>--}}
									{{--</td>--}}

									{{--<td>--}}
										{{--<div class="hidden-sm hidden-xs action-buttons">--}}
											{{--<a class="blue" href="#">--}}
												{{--<i class="ace-icon fa fa-search-plus bigger-130"></i>--}}
											{{--</a>--}}

											{{--<a class="green" href="#">--}}
												{{--<i class="ace-icon fa fa-pencil bigger-130"></i>--}}
											{{--</a>--}}

											{{--<a class="red" href="#">--}}
												{{--<i class="ace-icon fa fa-trash-o bigger-130"></i>--}}
											{{--</a>--}}
										{{--</div>--}}

										{{--<div class="hidden-md hidden-lg">--}}
											{{--<div class="inline pos-rel">--}}
												{{--<button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown" data-position="auto">--}}
													{{--<i class="ace-icon fa fa-caret-down icon-only bigger-120"></i>--}}
												{{--</button>--}}

												{{--<ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">--}}
													{{--<li>--}}
														{{--<a href="#" class="tooltip-info" data-rel="tooltip" title="View">--}}
															{{--<span class="blue">--}}
																{{--<i class="ace-icon fa fa-search-plus bigger-120"></i>--}}
															{{--</span>--}}
														{{--</a>--}}
													{{--</li>--}}

													{{--<li>--}}
														{{--<a href="#" class="tooltip-success" data-rel="tooltip" title="Edit">--}}
															{{--<span class="green">--}}
																{{--<i class="ace-icon fa fa-pencil-square-o bigger-120"></i>--}}
															{{--</span>--}}
														{{--</a>--}}
													{{--</li>--}}

													{{--<li>--}}
														{{--<a href="#" class="tooltip-error" data-rel="tooltip" title="Delete">--}}
															{{--<span class="red">--}}
																{{--<i class="ace-icon fa fa-trash-o bigger-120"></i>--}}
															{{--</span>--}}
														{{--</a>--}}
													{{--</li>--}}
												{{--</ul>--}}
											{{--</div>--}}
										{{--</div>--}}
									{{--</td>--}}
								{{--</tr>--}}

							</tbody>
						</table>
					</div>
				</div>
			</div>
			<!-- PAGE CONTENT ENDS -->
		</div><!-- /.col -->

		<div class="modal-footer no-margin-top">
			{{--<ul class="pagination pull-right no-margin">--}}
				{{--<li class="prev disabled">--}}
					{{--<a href="#">--}}
						{{--<i class="ace-icon fa fa-angle-double-left"></i>--}}
					{{--</a>--}}
				{{--</li>--}}

				{{--<li class="active">--}}
					{{--<a href="#">1</a>--}}
				{{--</li>--}}

				{{--<li>--}}
					{{--<a href="#">2</a>--}}
				{{--</li>--}}

				{{--<li>--}}
					{{--<a href="#">3</a>--}}
				{{--</li>--}}

				{{--<li class="next">--}}
					{{--<a href="#">--}}
						{{--<i class="ace-icon fa fa-angle-double-right"></i>--}}
					{{--</a>--}}
				{{--</li>--}}
			{{--</ul>--}}
			@if(empty($url_data))
				{{ $list->links() }}
			@else
				{{$list->appends($url_data)->links() }}
			@endif
		</div>
	</div><!-- /.row -->
</div><!-- /.page-content -->
<script>
	function searchThis(obj) {
	    var $search = obj.value;
	    if ($search.length != 0){
	        var url = '{{$list->url(1)}}&name='+$search;
			console.log(url);
			location.href = url;
		}
		console.log(obj);
		console.log($search);
    }
    function delData(id) {

	    layer.confirm('确定删除吗？',
			{btn:['确认','取消']},
			function(){
                var url = '{{url('admin/admin/')}}/'+id;

                $.ajax({
                    url:url,
                    type:'delete',
                    data:{_token: '{{csrf_token()}}'},
                    success:function(res){
                        if(res.status == 1){
                            layer.msg(res.msg,{icon:1});
                            location.reload();
                        }else{
                            layer.msg(res.msg,{icon:2});
                        }
                    }
                });
			},
			function () {
				layer.closeAll();
            }

		);
    }
</script>
@endsection
